function my$(id) {
    return document.getElementById(id);
  }

function Q1() {
    let a = 1;
    let b = 2;
    [a,b] = [b,a]
    console.log(`a=${a},b=${b}`);

}


function Q2() {
    let temp = [1,1,2,3,3,3,3,4,5,5,6,7]
    let result = new Set();
    for (i of temp){
        result.add(i)
    }
    console.log(temp)
    console.log(result)
}

function Q4() {
    let reg = /^(\-|\+)?\d+(\.\d+)?$/
    let temp = "0.41323"
    if(reg.test(temp)){
        console.log(`测试字符串为${temp},该字符串是由数字组成`)
    }else{
        console.log(`测试字符串为${temp},该字符串不是由纯数字组成`)
    }
}


function Q5() {
    var reg = /^\d{3,4}-\d{8}$/;
    let temp = "020-13242345"
    if(reg.test(temp)){
        console.log(`测试字符串为${temp},该字符串是本地电话号码`)
    }else{
        console.log(`测试字符串为${temp},该字符串不是本地电话号码`)
    }
}

function Q6() {
    let reg = /[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/
    while (true){
        let k = prompt("输入一个网址");
        if (reg.test(k)){
            break;
        } else {
            continue;
        }
    }
    let result = k.replace(/\.[0-z]+\./,'.lagou.')
    console.log(result);
}

function Q7() {
    let temp = "  0123124123"
    function trim(str){
        return str.replace(/^\s/,'');
    }
    console.log(trim(temp));
}

function Q8() {
    let temp = "<p class='demo'>hello JavaScript</p>"
    let reg = new RegExp('<(\S*?)[^>]*>.*?|<.*? />','g')
    let result = temp.replace(reg,"")
    console.log(result);
}

function Q9() {
    let temp = "div#demo.demo"
    let reg = new RegExp('div#([^\.]*)\.(.*)$','g')
    let reg1 = /(?<=#)(\w*)/
    let reg2 = /(?<=\.)(\w*)/
    let result1 = temp.match(reg1)[0]
    let result2 = temp.match(reg2)[0]
    console.log(`<div id="${result1}" class="${result2}"></div>`);
}

function Q10() {
    let reg = /^[\u4e00-\u9fa5]{0,}$/
    while (true){
        let k = prompt("输入一些汉字");
        if (reg.test(k)){
            break;
        } else {
            continue;
        }
    }
    let reg1 = /^[\u4e00-\u9fa5]{2,4}$/
    if(reg1.test(k)){
        console.log(`测试字符串为${k},该字符串是2-4位汉字`)
    }else{
        console.log(`测试字符串为${k},该字符串不是2-4位汉字`)
    }
}

function Q11() {
    let k = prompt("输入一些内容");
    let reg = /^[\u4e00-\u9fa50-z_]{6,8}$/
    if(reg.test(k)){
        console.log(`测试字符串为${k},该字符串是由6-8位汉字字母数字下划线组成`)
    }else{
        console.log(`测试字符串为${k},该字符串不是由6-8位汉字字母数字下划线组成`)
    }
}




